<template>
    <div class="nowtime">{{yy}}年{{MM}}月{{dd}}日 {{hh}}:{{mm}}:{{ss}}</div>
</template>

<script>
    export default {
        name: "nowtime",
        data(){
            return {
                yy:0,
                MM:0,
                dd:0,
                hh:0,
                mm:0,
                ss:0
            }
        },
        created(){
            setInterval(()=>{
                let time = new Date();
                this.yy = time.getFullYear();
                this.MM = time.getMonth()+1;
                this.dd = time.getDate();
                this.hh = this.buling(time.getHours());
                this.mm = this.buling(time.getMinutes());
                this.ss = this.buling(time.getSeconds());
            },1000)
        },
        methods:{
            buling(n){
                if(n<10){
                    return '0'+n;
                }else {
                    return n;
                }
            }
        }
    }
</script>

<style scoped>
    .nowtime{
        height: 38px;
        border: 1px solid #2047a0;
        line-height: 38px;
        color: #fff;
        padding: 0 24px;
        font-size: 22px;
    }
</style>
